<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>apache的扩展模块安装 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>apache的扩展模块安装</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Apache/">Apache</a> <a class="article__tag-link" href="/tags/LAMP/">LAMP</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这个用到了apache的扩展工具  apxs</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在使用这个功能之前，请先确认是否已经加载了 mod_so 模块，方法是：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/apache2/bin/httpd -l</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在列出的内容中，如果有 mod_so 那么说明已经加载了该模块。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下面，举个例子来演示一下，如何编译安装扩展模块，例如，我想增加  mod_status.so 这个模块</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/apache2/bin/apxs -i -a -c mod_status.c</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;请注意，这里的mod_status.c 的路径一定要写对了，不然会报错，一般情况下，这个C文件在你的源码包下，比如：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/src/httpd-2.0.59/modules/generators/mod_status.c</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;编译的结果类似这样：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/services/apache-2.0.59/build/libtool --silent --mode=compile gcc -prefer-pic -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/<span class="built_in">local</span>/services/apache-2.0.59/include -I/usr/<span class="built_in">local</span>/services/apache-2.0.59/include -I/usr/<span class="built_in">local</span>/services/apache-2.0.59/include -c -o /root/httpd-2.0.64/modules/generators/mod_status.lo /root/httpd-2.0.64/modules/generators/mod_status.c &amp;&amp; touch /root/httpd-2.0.64/modules/generators/mod_status.slo</div><div class="line">/usr/<span class="built_in">local</span>/services/apache-2.0.59/build/libtool --silent --mode=link gcc -o /root/httpd-2.0.64/modules/generators/mod_status.la -rpath /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules -module -avoid-version /root/httpd-2.0.64/modules/generators/mod_status.lo</div><div class="line">/usr/<span class="built_in">local</span>/services/apache-2.0.59/build/instdso.sh SH_LIBTOOL=<span class="string">'/usr/local/services/apache-2.0.59/build/libtool'</span> /root/httpd-2.0.64/modules/generators/mod_status.la /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules</div><div class="line">/usr/<span class="built_in">local</span>/services/apache-2.0.59/build/libtool --mode=install cp /root/httpd-2.0.64/modules/generators/mod_status.la /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules/</div><div class="line">cp /root/httpd-2.0.64/modules/generators/.libs/mod_status.so /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules/mod_status.so</div><div class="line">cp /root/httpd-2.0.64/modules/generators/.libs/mod_status.lai /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules/mod_status.la</div><div class="line">cp /root/httpd-2.0.64/modules/generators/.libs/mod_status.a /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules/mod_status.a</div><div class="line">ranlib /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules/mod_status.a</div><div class="line">chmod 644 /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules/mod_status.a</div><div class="line">PATH=<span class="string">"<span class="variable">$PATH</span>:/sbin"</span> ldconfig -n /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules</div><div class="line">----------------------------------------------------------------------</div><div class="line">Libraries have been installed <span class="keyword">in</span>:</div><div class="line"> /usr/<span class="built_in">local</span>/services/apache-2.0.59/modules</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;完成后，请看提示 Libraries have been installed in:  模块就会安装到这里了。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Apache/14. apache的扩展模块安装/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
